package com.example.onedemotest.slice;

import com.example.onedemotest.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.AdaptiveBoxLayout;

public class AdaptiveBoxLayoutSlice extends AbilitySlice {
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_slice_adaptive_box_layout);
        AdaptiveBoxLayout adaptiveBoxLayout= (AdaptiveBoxLayout) findComponentById(ResourceTable.Id_adaptiveBoxLayout);
        adaptiveBoxLayout.clearAdaptiveRules();
        //当屏幕宽度为0-1000 时候 摆放两个控件
        adaptiveBoxLayout.addAdaptiveRule(0,1000,2);
        adaptiveBoxLayout.addAdaptiveRule(1000,2000,3);
        adaptiveBoxLayout.addAdaptiveRule(2000,3000,4);
    }
}


